package com.example.lucky.draw.user.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;

@Configuration
public class CorsGlobalConfiguration implements WebFluxConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**") //对所有路径应用CORS配置
                .allowedOrigins("http://localhost:8080") //允许所有来源
                .allowedMethods("*") //允许GET、POST请求
                .allowedHeaders("*") //允许所有头部信息
                .allowCredentials(true) //允许携带cookie
                .maxAge(3600); //预检请求的有效期为1小时
    }

}
